package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@Api("店铺相关接口")
@Slf4j
@RequestMapping("/admin/shop")
public class ShopController {
    @Autowired
    RedisTemplate redisTemplate;
    /**
     * 设置店铺营业状态
     */
    @ApiOperation("设置店铺营业状态")
    @PutMapping("/{status}")
    public Result updateStatus(@PathVariable("status") Integer status) {
        log.info("status:{}", status);
        redisTemplate.opsForValue().set("shopStatus", status);
        return Result.success();
    }
    @ApiOperation("设置营业状态")
    @GetMapping("/status")
    public Result<Integer> getStatus() {
        log.info("status");
        return Result.success((Integer) redisTemplate.opsForValue().get("shopStatus"));
    }
}
